<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>fdk-aac: original/libSBRdec/src/env_calc.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">fdk-aac
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_ed137715e08969a186ec660e8ae6e2fb.html">original</a></li><li class="navelem"><a class="el" href="dir_222de58a05c98cc4a78309a37525cd28.html">libSBRdec</a></li><li class="navelem"><a class="el" href="dir_c997d48ad60fbe63e2ba342b9c79db98.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">env_calc.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Envelope calculation prototypes.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;sbrdecoder.h&quot;</code><br />
<code>#include &quot;<a class="el" href="env__extr_8h_source.html">env_extr.h</a>&quot;</code><br />
</div>
<p><a href="env__calc_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">SBR_CALCULATE_ENVELOPE</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ab7166c5bf83882a735e33575078abd75"><td class="memItemLeft" align="right" valign="top"><a id="ab7166c5bf83882a735e33575078abd75"></a>
typedef <a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">SBR_CALCULATE_ENVELOPE</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>HANDLE_SBR_CALCULATE_ENVELOPE</b></td></tr>
<tr class="separator:ab7166c5bf83882a735e33575078abd75"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aae9d37db2f742e05b12777329810dda8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#aae9d37db2f742e05b12777329810dda8">calculateSbrEnvelope</a> (<a class="el" href="struct_q_m_f___s_c_a_l_e___f_a_c_t_o_r.html">QMF_SCALE_FACTOR</a> *sbrScaleFactor, <a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a> h_sbr_cal_env, <a class="el" href="struct_s_b_r___h_e_a_d_e_r___d_a_t_a.html">HANDLE_SBR_HEADER_DATA</a> hHeaderData, <a class="el" href="struct_s_b_r___f_r_a_m_e___d_a_t_a.html">HANDLE_SBR_FRAME_DATA</a> hFrameData, <a class="el" href="struct_p_v_c___d_y_n_a_m_i_c___d_a_t_a.html">PVC_DYNAMIC_DATA</a> *pPvcDynamicData, FIXP_DBL **analysBufferReal, FIXP_DBL **analysBufferImag, const int useLP, FIXP_DBL *degreeAlias, const <a class="el" href="machine__type_8h.html#afff0ab3629a68bc1bb3b2a2f4296173f">UINT</a> flags, const int frameErrorFlag)</td></tr>
<tr class="memdesc:aae9d37db2f742e05b12777329810dda8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply spectral envelope to subband samples.  <a href="env__calc_8h.html#aae9d37db2f742e05b12777329810dda8">More...</a><br /></td></tr>
<tr class="separator:aae9d37db2f742e05b12777329810dda8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1de7071c6c4fc263d7061ed5af39a797"><td class="memItemLeft" align="right" valign="top">SBR_ERROR&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#a1de7071c6c4fc263d7061ed5af39a797">createSbrEnvelopeCalc</a> (<a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a> hSbrCalculateEnvelope, <a class="el" href="struct_s_b_r___h_e_a_d_e_r___d_a_t_a.html">HANDLE_SBR_HEADER_DATA</a> hHeaderData, const int chan, const <a class="el" href="machine__type_8h.html#afff0ab3629a68bc1bb3b2a2f4296173f">UINT</a> flags)</td></tr>
<tr class="memdesc:a1de7071c6c4fc263d7061ed5af39a797"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create envelope instance.  <a href="env__calc_8h.html#a1de7071c6c4fc263d7061ed5af39a797">More...</a><br /></td></tr>
<tr class="separator:a1de7071c6c4fc263d7061ed5af39a797"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c8be6ca2ff6e86120d1884dfa32df92"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#a7c8be6ca2ff6e86120d1884dfa32df92">deleteSbrEnvelopeCalc</a> (<a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a> hSbrCalculateEnvelope)</td></tr>
<tr class="memdesc:a7c8be6ca2ff6e86120d1884dfa32df92"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create envelope instance.  <a href="env__calc_8h.html#a7c8be6ca2ff6e86120d1884dfa32df92">More...</a><br /></td></tr>
<tr class="separator:a7c8be6ca2ff6e86120d1884dfa32df92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3743b36f9164a7950fc449e4cf1f378e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#a3743b36f9164a7950fc449e4cf1f378e">resetSbrEnvelopeCalc</a> (<a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a> hCalEnv)</td></tr>
<tr class="memdesc:a3743b36f9164a7950fc449e4cf1f378e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset envelope instance.  <a href="env__calc_8h.html#a3743b36f9164a7950fc449e4cf1f378e">More...</a><br /></td></tr>
<tr class="separator:a3743b36f9164a7950fc449e4cf1f378e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adea15b20c9bfc9c7d43ab5b3bdd5254c"><td class="memItemLeft" align="right" valign="top">SBR_ERROR&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#adea15b20c9bfc9c7d43ab5b3bdd5254c">ResetLimiterBands</a> (<a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *limiterBandTable, <a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *noLimiterBands, <a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *freqBandTable, int noFreqBands, const <a class="el" href="struct_p_a_t_c_h___p_a_r_a_m.html">PATCH_PARAM</a> *patchParam, int noPatches, int limiterBands, <a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> sbrPatchingMode, int xOverQmf[MAX_NUM_PATCHES], int sbrRatio)</td></tr>
<tr class="memdesc:adea15b20c9bfc9c7d43ab5b3bdd5254c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset limiter bands.  <a href="env__calc_8h.html#adea15b20c9bfc9c7d43ab5b3bdd5254c">More...</a><br /></td></tr>
<tr class="separator:adea15b20c9bfc9c7d43ab5b3bdd5254c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5224ceaceb223654255cd788d45120cc"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#a5224ceaceb223654255cd788d45120cc">rescaleSubbandSamples</a> (FIXP_DBL **re, FIXP_DBL **im, int lowSubband, int noSubbands, int start_pos, int next_pos, int shift)</td></tr>
<tr class="memdesc:a5224ceaceb223654255cd788d45120cc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Shift left the mantissas of all subband samples in the giventime and frequency range by the specified number of bits.  <a href="env__calc_8h.html#a5224ceaceb223654255cd788d45120cc">More...</a><br /></td></tr>
<tr class="separator:a5224ceaceb223654255cd788d45120cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a337d16cd9afb7a6ebe08231d376ca93f"><td class="memItemLeft" align="right" valign="top">FIXP_DBL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="env__calc_8h.html#a337d16cd9afb7a6ebe08231d376ca93f">maxSubbandSample</a> (FIXP_DBL **analysBufferReal_m, FIXP_DBL **analysBufferImag_m, int lowSubband, int highSubband, int start_pos, int stop_pos)</td></tr>
<tr class="memdesc:a337d16cd9afb7a6ebe08231d376ca93f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Determine headroom for shifting.  <a href="env__calc_8h.html#a337d16cd9afb7a6ebe08231d376ca93f">More...</a><br /></td></tr>
<tr class="separator:a337d16cd9afb7a6ebe08231d376ca93f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Envelope calculation prototypes. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="aae9d37db2f742e05b12777329810dda8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aae9d37db2f742e05b12777329810dda8">&#9670;&nbsp;</a></span>calculateSbrEnvelope()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void calculateSbrEnvelope </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_q_m_f___s_c_a_l_e___f_a_c_t_o_r.html">QMF_SCALE_FACTOR</a> *&#160;</td>
          <td class="paramname"><em>sbrScaleFactor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a>&#160;</td>
          <td class="paramname"><em>h_sbr_cal_env</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___h_e_a_d_e_r___d_a_t_a.html">HANDLE_SBR_HEADER_DATA</a>&#160;</td>
          <td class="paramname"><em>hHeaderData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___f_r_a_m_e___d_a_t_a.html">HANDLE_SBR_FRAME_DATA</a>&#160;</td>
          <td class="paramname"><em>hFrameData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_p_v_c___d_y_n_a_m_i_c___d_a_t_a.html">PVC_DYNAMIC_DATA</a> *&#160;</td>
          <td class="paramname"><em>pPvcDynamicData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>analysBufferReal</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>analysBufferImag</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int&#160;</td>
          <td class="paramname"><em>useLP</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FIXP_DBL *&#160;</td>
          <td class="paramname"><em>degreeAlias</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="machine__type_8h.html#afff0ab3629a68bc1bb3b2a2f4296173f">UINT</a>&#160;</td>
          <td class="paramname"><em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int&#160;</td>
          <td class="paramname"><em>frameErrorFlag</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply spectral envelope to subband samples. </p>
<p>This function is called from <a class="el" href="sbr__dec_8cpp.html" title="Sbr decoder This module provides the actual decoder implementation. The SBR data (side information) i...">sbr_dec.cpp</a> in each frame.</p>
<p>To enhance accuracy and due to the usage of tables for squareroots and inverse, some calculations are performed with the operands being split into mantissa and exponent. The variable names in the source code carry the suffixes <em>_m</em> and <em>_e</em> respectively. The control data in #hFrameData containts envelope data which is represented by this format but stored in single words. (See requantizeEnvelopeData() for details). This data is unpacked within <a class="el" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8" title="Apply spectral envelope to subband samples.">calculateSbrEnvelope()</a> to follow the described suffix convention.</p>
<p>The actual value (comparable to the corresponding float-variable in the research-implementation) of a mantissa/exponent-pair can be calculated as</p>
<p><img class="formulaInl" alt="$ value = value\_m * 2^{value\_e} $" src="form_8.png"/></p>
<p>All energies and noise levels decoded from the bitstream suit for an original signal magnitude of <img class="formulaInl" alt="$\pm 32768 $" src="form_9.png"/> rather than <img class="formulaInl" alt="$ \pm 1$" src="form_10.png"/>. Therefore, the scale factor <em>hb_scale</em> passed into this function will be converted to an 'input exponent' (#input_e), which fits the internal representation.</p>
<p>Before the actual processing, an exponent #adj_e for resulting adjusted samples is derived from the maximum reference energy.</p>
<p>Then, for each envelope, the following steps are performed:</p>
<ul>
<li>Calculate energy in the signal to be adjusted. Depending on the the value of #interpolFreq (interpolation mode), this is either done seperately for each QMF-subband or for each SBR-band. The resulting energies are stored in #nrgEst_m[#MAX_FREQ_COEFFS] (mantissas) and #nrgEst_e[#MAX_FREQ_COEFFS] (exponents). </li>
<li>Calculate gain and noise level for each subband:<br  />
 <img class="formulaInl" alt="$ gain = \sqrt{ \frac{nrgRef}{nrgEst} \cdot (1 - noiseRatio) } \hspace{2cm} noise = \sqrt{ nrgRef \cdot noiseRatio } $" src="form_11.png"/><br  />
 where <em>noiseRatio</em> and <em>nrgRef</em> are extracted from the bitstream and <em>nrgEst</em> is the subband energy before adjustment. The resulting gains are stored in #nrgGain_m[#MAX_FREQ_COEFFS] (mantissas) and #nrgGain_e[#MAX_FREQ_COEFFS] (exponents), the noise levels are stored in #noiseLevel_m[#MAX_FREQ_COEFFS] and #noiseLevel_e[#MAX_FREQ_COEFFS] (exponents). The sine levels are stored in #nrgSine_m[#MAX_FREQ_COEFFS] and #nrgSine_e[#MAX_FREQ_COEFFS]. </li>
<li>Noise limiting: The gain for each subband is limited both absolutely and relatively compared to the total gain over all subbands. </li>
<li>Boost gain: Calculate and apply boost factor for each limiter band in order to compensate for the energy loss imposed by the limiting. </li>
<li>Apply gains and add noise: The gains and noise levels are applied to all timeslots of the current envelope. A short FIR-filter (length 4 QMF-timeslots) can be used to smooth the sudden change at the envelope borders. Each complex subband sample of the current timeslot is multiplied by the smoothed gain, then random noise with the calculated level is added.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>To reduce the stack size, some of the local arrays could be located within the time output buffer. Of the 512 samples temporarily available there, about half the size is already used by <a class="el" href="struct_s_b_r___f_r_a_m_e___d_a_t_a.html">SBR_FRAME_DATA</a>. A pointer to the remaining free memory could be supplied by an additional argument to <a class="el" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8" title="Apply spectral envelope to subband samples.">calculateSbrEnvelope()</a> in sbr_dec:</dd></dl>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line">  <a class="code" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8">calculateSbrEnvelope</a> (&amp;hSbrDec-&gt;sbrScaleFactor,</div>
<div class="line">                        &amp;hSbrDec-&gt;SbrCalculateEnvelope,</div>
<div class="line">                        hHeaderData,</div>
<div class="line">                        hFrameData,</div>
<div class="line">                        QmfBufferReal,</div>
<div class="line">                        QmfBufferImag,</div>
<div class="line">                        timeOutPtr + <span class="keyword">sizeof</span>(<a class="code" href="struct_s_b_r___f_r_a_m_e___d_a_t_a.html">SBR_FRAME_DATA</a>)/<span class="keyword">sizeof</span>(Float) +</div>
<div class="line">1); </div>
<div class="ttc" id="aenv__calc_8cpp_html_aae9d37db2f742e05b12777329810dda8"><div class="ttname"><a href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8">calculateSbrEnvelope</a></div><div class="ttdeci">void calculateSbrEnvelope(QMF_SCALE_FACTOR *sbrScaleFactor, HANDLE_SBR_CALCULATE_ENVELOPE h_sbr_cal_env, HANDLE_SBR_HEADER_DATA hHeaderData, HANDLE_SBR_FRAME_DATA hFrameData, PVC_DYNAMIC_DATA *pPvcDynamicData, FIXP_DBL **analysBufferReal, FIXP_DBL **analysBufferImag, const int useLP, FIXP_DBL *degreeAlias, const UINT flags, const int frameErrorFlag)</div><div class="ttdoc">Apply spectral envelope to subband samples.</div><div class="ttdef"><b>Definition:</b> env_calc.cpp:876</div></div>
<div class="ttc" id="astruct_s_b_r___f_r_a_m_e___d_a_t_a_html"><div class="ttname"><a href="struct_s_b_r___f_r_a_m_e___d_a_t_a.html">SBR_FRAME_DATA</a></div><div class="ttdef"><b>Definition:</b> env_extr.h:330</div></div>
</div><!-- fragment --></dd></dl>
<dl class="section user"><dt></dt><dd>Within <a class="el" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8" title="Apply spectral envelope to subband samples.">calculateSbrEnvelope()</a>, some pointers could be defined instead of the arrays #nrgRef_m, #nrgRef_e, #nrgEst_m, #nrgEst_e, #noiseLevel_m:</dd></dl>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line">fract*        nrgRef_m = timeOutPtr;</div>
<div class="line"><a class="code" href="machine__type_8h.html#af3e70e9edd31fb299154d959c70ac6bf">SCHAR</a>*        nrgRef_e = nrgRef_m + MAX_FREQ_COEFFS;</div>
<div class="line">fract*        nrgEst_m = nrgRef_e + MAX_FREQ_COEFFS;</div>
<div class="line"><a class="code" href="machine__type_8h.html#af3e70e9edd31fb299154d959c70ac6bf">SCHAR</a>*        nrgEst_e = nrgEst_m + MAX_FREQ_COEFFS;</div>
<div class="line">fract*        noiseLevel_m = nrgEst_e + MAX_FREQ_COEFFS;</div>
<div class="ttc" id="amachine__type_8h_html_af3e70e9edd31fb299154d959c70ac6bf"><div class="ttname"><a href="machine__type_8h.html#af3e70e9edd31fb299154d959c70ac6bf">SCHAR</a></div><div class="ttdeci">signed char SCHAR</div><div class="ttdef"><b>Definition:</b> machine_type.h:189</div></div>
</div><!-- fragment --></dd></dl>
<p><br  />
 </p>
<p>Upper limit of the current noise floor band.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sbrScaleFactor</td><td>Scaling factors </td></tr>
    <tr><td class="paramname">h_sbr_cal_env</td><td>Handle to struct filled by the create-function </td></tr>
    <tr><td class="paramname">hHeaderData</td><td>Static control data </td></tr>
    <tr><td class="paramname">hFrameData</td><td>Control data of current frame </td></tr>
    <tr><td class="paramname">analysBufferReal</td><td>Real part of subband samples to be processed </td></tr>
    <tr><td class="paramname">analysBufferImag</td><td>Imag part of subband samples to be processed </td></tr>
    <tr><td class="paramname">degreeAlias</td><td>Estimated aliasing for each QMF channel </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a1de7071c6c4fc263d7061ed5af39a797"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1de7071c6c4fc263d7061ed5af39a797">&#9670;&nbsp;</a></span>createSbrEnvelopeCalc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">SBR_ERROR createSbrEnvelopeCalc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a>&#160;</td>
          <td class="paramname"><em>hs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___h_e_a_d_e_r___d_a_t_a.html">HANDLE_SBR_HEADER_DATA</a>&#160;</td>
          <td class="paramname"><em>hHeaderData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int&#160;</td>
          <td class="paramname"><em>chan</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="machine__type_8h.html#afff0ab3629a68bc1bb3b2a2f4296173f">UINT</a>&#160;</td>
          <td class="paramname"><em>flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create envelope instance. </p>
<p>Must be called once for each channel before <a class="el" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8" title="Apply spectral envelope to subband samples.">calculateSbrEnvelope()</a> can be used.</p>
<dl class="section return"><dt>Returns</dt><dd>errorCode, 0 if successful </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">hs</td><td>pointer to envelope instance </td></tr>
    <tr><td class="paramname">hHeaderData</td><td>static SBR control data, initialized with defaults </td></tr>
    <tr><td class="paramname">chan</td><td>Channel for which to assign buffers </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a7c8be6ca2ff6e86120d1884dfa32df92"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7c8be6ca2ff6e86120d1884dfa32df92">&#9670;&nbsp;</a></span>deleteSbrEnvelopeCalc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int deleteSbrEnvelopeCalc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a>&#160;</td>
          <td class="paramname"><em>hs</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create envelope instance. </p>
<p>Must be called once for each channel before <a class="el" href="env__calc_8cpp.html#aae9d37db2f742e05b12777329810dda8" title="Apply spectral envelope to subband samples.">calculateSbrEnvelope()</a> can be used.</p>
<dl class="section return"><dt>Returns</dt><dd>errorCode, 0 if successful </dd></dl>

</div>
</div>
<a id="a337d16cd9afb7a6ebe08231d376ca93f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a337d16cd9afb7a6ebe08231d376ca93f">&#9670;&nbsp;</a></span>maxSubbandSample()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">FIXP_DBL maxSubbandSample </td>
          <td>(</td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>re</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>lowSubband</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>highSubband</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>start_pos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>next_pos</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Determine headroom for shifting. </p>
<p>Determine by how much the spectrum can be shifted left for better accuracy in later processing.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of free bits in the biggest spectral value </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">re</td><td>Real part of input and output subband samples </td></tr>
    <tr><td class="paramname">im</td><td>Real part of input and output subband samples </td></tr>
    <tr><td class="paramname">lowSubband</td><td>Begin of frequency range to process </td></tr>
    <tr><td class="paramname">highSubband</td><td>Number of QMF bands to process </td></tr>
    <tr><td class="paramname">start_pos</td><td>Begin of time rage (QMF-timeslot) </td></tr>
    <tr><td class="paramname">next_pos</td><td>End of time rage (QMF-timeslot) </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a5224ceaceb223654255cd788d45120cc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5224ceaceb223654255cd788d45120cc">&#9670;&nbsp;</a></span>rescaleSubbandSamples()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void rescaleSubbandSamples </td>
          <td>(</td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>re</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FIXP_DBL **&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>lowSubband</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>highSubband</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>start_pos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>next_pos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>shift</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Shift left the mantissas of all subband samples in the giventime and frequency range by the specified number of bits. </p>
<p>This function is used to rescale the audio data in the overlap buffer which has already been envelope adjusted with the last frame. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">re</td><td>Real part of input and output subband samples </td></tr>
    <tr><td class="paramname">im</td><td>Imaginary part of input and output subband samples </td></tr>
    <tr><td class="paramname">lowSubband</td><td>Begin of frequency range to process </td></tr>
    <tr><td class="paramname">highSubband</td><td>End of frequency range to process </td></tr>
    <tr><td class="paramname">start_pos</td><td>Begin of time rage (QMF-timeslot) </td></tr>
    <tr><td class="paramname">next_pos</td><td>End of time rage (QMF-timeslot) </td></tr>
    <tr><td class="paramname">shift</td><td>number of bits to shift </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="adea15b20c9bfc9c7d43ab5b3bdd5254c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adea15b20c9bfc9c7d43ab5b3bdd5254c">&#9670;&nbsp;</a></span>ResetLimiterBands()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">SBR_ERROR ResetLimiterBands </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *&#160;</td>
          <td class="paramname"><em>limiterBandTable</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *&#160;</td>
          <td class="paramname"><em>noLimiterBands</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a> *&#160;</td>
          <td class="paramname"><em>freqBandTable</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>noFreqBands</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="struct_p_a_t_c_h___p_a_r_a_m.html">PATCH_PARAM</a> *&#160;</td>
          <td class="paramname"><em>patchParam</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>noPatches</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>limiterBands</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="machine__type_8h.html#aed5a2dbe32af3a91203f0f5e8697e873">UCHAR</a>&#160;</td>
          <td class="paramname"><em>sbrPatchingMode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>xOverQmf</em>[MAX_NUM_PATCHES], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>b41Sbr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reset limiter bands. </p>
<p>Build frequency band table for the gain limiter dependent on the previously generated transposer patch areas.</p>
<dl class="section return"><dt>Returns</dt><dd>SBRDEC_OK if ok, SBRDEC_UNSUPPORTED_CONFIG on error </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">limiterBandTable</td><td>Resulting band borders in QMF channels </td></tr>
    <tr><td class="paramname">noLimiterBands</td><td>Resulting number of limiter band </td></tr>
    <tr><td class="paramname">freqBandTable</td><td>Table with possible band borders </td></tr>
    <tr><td class="paramname">noFreqBands</td><td>Number of bands in freqBandTable </td></tr>
    <tr><td class="paramname">patchParam</td><td>Transposer patch parameters </td></tr>
    <tr><td class="paramname">noPatches</td><td>Number of transposer patches </td></tr>
    <tr><td class="paramname">limiterBands</td><td>Selected 'band density' from bitstream </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a3743b36f9164a7950fc449e4cf1f378e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3743b36f9164a7950fc449e4cf1f378e">&#9670;&nbsp;</a></span>resetSbrEnvelopeCalc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void resetSbrEnvelopeCalc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_s_b_r___c_a_l_c_u_l_a_t_e___e_n_v_e_l_o_p_e.html">HANDLE_SBR_CALCULATE_ENVELOPE</a>&#160;</td>
          <td class="paramname"><em>hCalEnv</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reset envelope instance. </p>
<p>This function must be called for each channel on a change of configuration. Note that resetFreqBandTables should also be called in this case.</p>
<dl class="section return"><dt>Returns</dt><dd>errorCode, 0 if successful </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">hCalEnv</td><td>pointer to envelope instance </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
